#include "seatshowinfodialog.h"
#include "ui_seatshowinfodialog.h"

SeatShowInfoDialog::SeatShowInfoDialog(QVector3D *angle,
                                       QVector3D *scale,
                                       QVector3D *pos,
                                       QWidget *parent)
    : QDialog(parent)
    , angle(angle)
    , scale(scale)
    , pos(pos)
    , ui(new Ui::SeatShowInfoDialog)
{
    ui->setupUi(this);

    ui->lineEditAngleX->setText(QString("%1").arg(angle->x()));
    ui->lineEditAngleY->setText(QString("%1").arg(angle->y()));
    ui->lineEditAngleZ->setText(QString("%1").arg(angle->z()));

    ui->lineEditScaleX->setText(QString("%1").arg(scale->x()));
    ui->lineEditScaleY->setText(QString("%1").arg(scale->y()));
    ui->lineEditScaleZ->setText(QString("%1").arg(scale->z()));

    ui->lineEditPosX->setText(QString("%1").arg(pos->x()));
    ui->lineEditPosY->setText(QString("%1").arg(pos->y()));
    ui->lineEditPosZ->setText(QString("%1").arg(pos->z()));

    connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &SeatShowInfoDialog::Accept);
}

SeatShowInfoDialog::~SeatShowInfoDialog()
{
    delete ui;
}

void SeatShowInfoDialog::Accept()
{
    float x = ui->lineEditAngleX->text().toFloat();
    angle->setX(x);
    angle->setY(ui->lineEditAngleY->text().toFloat());
    angle->setZ(ui->lineEditAngleZ->text().toFloat());

    scale->setX(ui->lineEditScaleX->text().toFloat());
    scale->setY(ui->lineEditScaleY->text().toFloat());
    scale->setZ(ui->lineEditScaleZ->text().toFloat());

    pos->setX(ui->lineEditPosX->text().toFloat());
    pos->setY(ui->lineEditPosY->text().toFloat());
    pos->setZ(ui->lineEditPosZ->text().toFloat());
}
